﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SeguroSoft.Models;
using SeguroSoft.Tests.Fakes;

namespace SeguroSoft.Tests.Model
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class TestRepositorioComentario
    {


        IRepositorioComentario FakeRepoComent;
        public TestRepositorioComentario()
        {
            
            List<Comentario> listacomentarios=new List<Comentario>();
            for (int i = 0; i < 5; i++) {
                Comentario coment = new Comentario();
                coment.IDComentario = i;
                coment.Fecha = System.DateTime.Now;
                coment.Titulo = "titulo" + i;
                coment.Contenido = "contenido" + i;
                coment.RankingServicio =  i;
                coment.Usuario = "juampi";
                listacomentarios.Add(coment);

            }
            FakeRepoComent = new FakeRepositorioComentario(listacomentarios);


        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void Comentario_se_agrega_correctamente()
        {

            Comentario coment = new Comentario();
            coment.IDComentario = 10;
            coment.Fecha = System.DateTime.Now;
            coment.Titulo = "titulo10";
            coment.Contenido = "contenido10";
            coment.RankingServicio = 10;
            coment.Usuario = "juampilon";
            FakeRepoComent.crearcomentario(coment);
            Assert.IsNotNull(FakeRepoComent.buscarcomentariosporid(10));



        }
        [TestMethod]
        public void Comentario_se_elimina_correctamente()
        {
            Comentario coment = FakeRepoComent.buscarcomentariosporid(1);
            FakeRepoComent.borrarcomentario(coment);
            Assert.IsNull(FakeRepoComent.buscarcomentariosporid(1));
        }
        [TestMethod]
        public void Comentario_se_busca_correctamente()
        {
            Comentario coment = FakeRepoComent.buscarcomentariosporid(1);
            Assert.IsNotNull(coment);
        }
    }
}
